<template>
	<scroll-view style="height: 100%;" scroll-y="true" @scrolltolower="lowerBottom">
		<uni-list>
			<uni-list-item direction="row" v-for="item in data" :key="item.id" :to="`/pages/detail?id=${item.id}`">
				<template v-slot:header>
					<view class="uni-thumb" v-if="item.image">
						<image :src="item.image" mode="aspectFill" style="width: 100%;height: 100%;"></image>
					</view>
				</template>
				<template v-slot:body>
					<view class="uni-list-box uni-content">
						<view class="title uni-ellipsis-2">
							{{item.title}}
						</view>
						<view class="date">
							{{item.createtime}}
						</view>
					</view>
				</template>
			</uni-list-item>
		</uni-list>
		<uni-load-more v-if="showLoad" :status="loadStatus" />
		<image src="https://zhzx.on-line-demo.com/image/zwsj.png" mode="aspectFit" class="no-data"
			v-if="loadStatus == 'no-more' && data.length == 0"></image>
	</scroll-view>
</template>

<script>
	import request from '../common/request.js'
	export default {
		components: {
			
		},
		data() {
			return {
				data:[],
				page: 1,
				loadStatus: 'loading',
				showLoad: false,
			}
		},
		mounted(){
			this.getListData()
		},
		methods: {
			lowerBottom(){
				if(this.loadStatus != 'loading'){
					this.loadStatus = 'loading'
					this.showLoad = true
					this.page++
					this.getListData()
				}
			},
			getListData(){
				request({
					url:'/news/newsList',
					data:{
						page: this.page,
						type: 4,  // 1资讯，2通知公告，3热点新闻，4会务动态
					},
					method:'POST',
				}).then(res => {
						if(res.code == 1){
							this.data = this.data.concat(res.data)
							if(this.page == res.lastPage){
								this.loadStatus = 'no-more'
							}else{
								this.loadStatus = 'more'
								this.showLoad = false
							}
						}else{
							this.loadStatus = 'no-more'
						}
					})
			},
		}
	}
</script>

<style scoped>
	.swiper-text{
		position: absolute;
		z-index: 9;
		bottom: 5px;
		left: 0px;
		width: 100%;
		text-align: center;
		font-size: 12px;
		color: #fff;
	}
</style>